import { getOptions } from "@/apis/optionApi";
import { ElMessageBox } from "element-plus";

//刑事强制措施字典
export const XingShiCuoShiDic = "/api/AnQing/GetXingShiCuoShiDic";
//是否类型字典
export const BoolDic = "/api/system/GetBoolDic"
//警情指标字典
export const JQZhibiaoDic = "/api/JingQing/GetZhiBiaoJiHe"
//案情指标字典
export const AQZhibiaoDic = "/api/AnQing/GetZhiBiaoJiHe"
//部门字典
export const DeptDic = "/api/System/GetDept"
//案件类别字典
export const KindDic = "/api/AnQing/GetAnJianLeiBieJiHe"

export interface ListOptions {
  value: string;
  label: string;
}

//动态获取是否参数
async function useGetOptions(url: string) {
  let options:ListOptions[] = []
  await getOptions(url)
    .then((res) => {
      if (res.code === 200) {
           options = res.result.map((item) => {
          return { value: item.Code, label: item.Name };
        });
      } else {
        ElMessageBox.alert("获取字典失败,请联系管理员" + res.message);
      }
    })
    .catch((error) => console.log("axios error " + error));
    return options;
}


export {useGetOptions}